home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
Twaindev.pxl
< prev
next >
Wrap
Text File
|
2000-04-17
|
7KB
|
250 lines
Initialize:
UseCoordinates(PIXEL)
SetColorPalette(BITMAP)
Title$ = "PiXCL 4.40 TWAIN device support"
UseCaption(Title$)
WinAdjustRect(150,200,880,635,MENU,wx1,wy1,wx2,wy2)
WinLocate(Title$,wx1,wy1,wx2,wy2,Res) {100,100,880,635}
WinShow(Title$,TOPMOST,Res)
ImageFile$ = ""
UseBackground(TRANSPARENT,166,166,166)
DrawBackground
DirGet(SourceDir$)
DirGetWindows(WinDir$)
DigiCamDir$ = WinDir$ + "\twain_32\dc120"
Image1$ = SourceDir$ + "\brsfbnd1.bmp"
Image2$ = SourceDir$ + "\brsfbnd2.bmp"
Image3$ = SourceDir$ + "\brsfbnd3.bmp"
Image4$ = SourceDir$ + "\brsfbnd4.bmp"
Image5$ = SourceDir$ + "\brsfbnd5.bmp"
Image7$ = SourceDir$ + "\brsfbnd7.bmp"
Image8$ = SourceDir$ + "\brsfc754.bmp"
Image9$ = SourceDir$ + "\brstclas.bmp"
Image10$ = SourceDir$ + "\brstgrid.bmp"
Image11$ = SourceDir$ + "\brstrans.bmp"
Image12$ = SourceDir$ + "\brstran1.bmp"
Image13$ = SourceDir$ + "\tw_image.bmp"
Chr(13,CR$)
UseFont("MS Sans Serif",11,23,NOBOLD,NOITALIC,NOUNDERLINE,255,0,0)
InitFile$ = "*.bmp"
InfoMenu(REMOVE)
WaitInput(100)
SetMenu("&File",IGNORE,
"&Manager Available",DeviceAvailable,
"&Select Source...",SelectDevice,
"&Acquire to List.",AcquireAnImage1,
"Parameters",BitmapParameters,
"Acquire to Clipboard",AcquireAnImage2,
"Empty Clipboard",ClearClipboard,
"Acquire to File",AcquireAnImage3,
SEPARATOR,
"Add a bitmap",AddBitmap,
"Show Image List",ListList,
"Free Image List",FreeList,
SEPARATOR,
"E&xit",Leave,
ENDPOPUP,
"TWAIN States",IGNORE,
"Run Test",RunStateTest,
ENDPOPUP)
StatusWindow(ENABLE,BOTTOM,2,250,-1,0,0)
DrawStatusWinText(0,"")
UseBackground(TRANSPARENT,166,166,166)
DrawBackground
Wait_for_Input:
WaitInput()
Leave:
TWAIN_CloseSourceManager(Res)
TWAIN_UnloadSourceManager(Res)
End
RunStateTest:
WinShow(Title$,NOTOPMOST,Res)
DrawBackground
TWAIN_GetState(Res)
DrawText(10,10,"Initial SM State") DrawNumber(150,10,Res)
TWAIN_LoadSourceManager(Res)
TWAIN_GetState(Res)
DrawText(10,30,"Loaded SM State") DrawNumber(150,30,Res)
TWAIN_OpenSourceManager(Res)
TWAIN_GetState(Res)
DrawText(10,50,"Opened SM State") DrawNumber(150,50,Res)
TWAIN_OpenDefaultSource(Res)
If Res = 0 Then Beep
TWAIN_GetState(Res)
DrawText(10,70,"Opened S State") DrawNumber(150,70,Res)
TWAIN_EnableSource(Res)
TWAIN_GetState(Res)
DrawText(10,90,"Enabled S State") DrawNumber(150,90,Res)
TWAIN_AcquireNative(Image13$,ANYTYPE,Handle)
WaitInput(2000)
TWAIN_GetState(Res)
DrawText(10,110,"Acquire State") DrawNumber(150,110,Res)
TWAIN_DisableSource(Res)
TWAIN_GetState(Res)
DrawText(10,130,"Disabled S State") DrawNumber(150,130,Res)
TWAIN_CloseSourceManager(Res)
TWAIN_GetState(Res)
DrawText(10,150,"Closed State") DrawNumber(150,150,Res)
TWAIN_UnLoadSourceManager(Res)
TWAIN_GetState(Res)
DrawText(10,170,"Unloaded State") DrawNumber(150,170,Res)
WinShow(Title$,TOPMOST,Res)
Goto Wait_for_Input
DeviceAvailable:
DrawBackground
TWAIN_IsAvailable(Res) DrawText(10,10,"Source Manager Available") DrawNumber(270,10,Res)
TWAIN_PXLVersion(Res) DrawText(10,30,"PXLtwain.dll version") DrawNumber(270,30,Res)
TWAIN_RegisterApp(4,14,100,100,"4.20","VYSOR","PiXCLTools","PiXCL")
Goto Wait_for_Input
SelectDevice:
DrawStatusWinText(0,"Loading TWAIN_32 Source Manager...")
WaitInput(1)
UseCursor(WAIT)
TWAIN_LoadSourceManager(Res)
TWAIN_OpenSourceManager(Res)
UseCursor(ARROW)
TWAIN_SelectSource(Res) { displays the Select Source dialog, selection is maintained}
DrawStatusWinText(0,"")
Goto Wait_for_Input
AcquireAnImage1:
TWAIN_UnloadSourceManager(Res)
DrawBackground
DrawStatusWinText(0,"Enable source and acquire an image...")
WaitInput(1)
WinShow(Title$,NOTOPMOST,Res)
UseCursor(WAIT)
TWAIN_EnableSource(Res)
TWAIN_AcquireNative(Image13$,ANYTYPE,Handle)
If Handle = 0 Then DrawStatusWinText(0,"Acquire Failed")
If Handle <> 0 Then DrawStatusWinText(0,"Acquire Successful")
UseCursor(ARROW)
ListLoadedBitmaps(List$,CR$,Count)
If Count > 0
{MessageBox(OK,1,INFORMATION,List$,"Loaded bitmaps",Res)}
{ConvertColorSpace(INDEXED,NONE,Res)}
DrawSizedBitmap(0,0,639,479,Image13$)
Endif
WinShow(Title$,TOPMOST,Res)
UseCursor(WAIT)
DrawStatusWinText(0,"Running Edge Detection...")
WaitInput(100)
EdgeDetectImage(Res)
UseCursor(ARROW)
DrawSizedBitmap(0,0,639,479,Image13$)
DrawStatusWinText(0,"")
Goto Wait_for_Input
BitmapParameters:
TWAIN_GetBitmapParams(Handle,Lines,Pixels,Bits,Colors)
DrawText(400,20,"Handle = ") DrawNumber(500,20,Handle)
DrawText(400,50,"Lines = ") DrawNumber(500,50,Lines)
DrawText(400,80,"Pixels = ") DrawNumber(500,80,Pixels)
DrawText(400,110,"Bits = ") DrawNumber(500,110,Bits)
DrawText(400,140,"ColorMap = ") DrawNumber(500,140,Colors)
WinShow(Title$,NOTOPMOST,Res)
UseCursor(WAIT)
TWAIN_LoadSourceManager(Res)
TWAIN_OpenSourceManager(Res)
TWAIN_OpenDefaultSource(Res)
TWAIN_GetState(State)
If State <> 4 Then Beep Beep Goto Wait_for_Input
TWAIN_GetPixelType(Type)
DrawText(400,170,"Pixel Type = ") DrawNumber(500,170,Type)
TWAIN_SetCurrentUnits(CENTIMETERS,Res)
TWAIN_GetCurrentUnits(Units)
If Units = 0 Then DrawText(400,190,"Units = INCHES")
If Units = 1 Then DrawText(400,190,"Units = CENTIMETERS")
If Units = 2 Then DrawText(400,190,"Units = PICAS")
If Units = 3 Then DrawText(400,190,"Units = POINTS")
If Units = 4 Then DrawText(400,190,"Units = TWIPS")
If Units = 5 Then DrawText(400,190,"Units = PIXELS")
TWAIN_GetCurrentRes(Resolution)
DrawText(400,210,"Resolution = ") DrawNumber(500,210,Resolution)
UseCursor(ARROW)
{clean up TWAIN access: should really be done for good coding practice,
though PiXCL will clean up when it exits.}
{TWAIN_CloseSource(Res)
TWAIN_CloseSourceManager(Res)
TWAIN_UnLoadSourceManager(Res)}
Goto Wait_for_Input
AcquireAnImage2:
DrawBackground
DrawStatusWinText(0,"Enable source and acquire an image...")
WaitInput(1)
WinShow(Title$,NOTOPMOST,Res)
UseCursor(WAIT)
TWAIN_EnableSource(Res)
TWAIN_AcquireToClipboard(Res)
If Res = 0 Then DrawStatusWinText(0,"Acquire to Clipboard Failed")
If Res = 1 Then DrawStatusWinText(0,"Acquire to Clipboard Successful")
UseCursor(ARROW)
Goto Wait_for_Input
ClearClipboard:
ClipboardEmpty {Clears out all text and binary data}
Goto Wait_for_Input
AcquireAnImage3:
DrawBackground
DrawStatusWinText(0,"Enable source and acquire an image...")
WaitInput(1)
WinShow(Title$,NOTOPMOST,Res)
UseCursor(WAIT)
TWAIN_EnableSource(Res)
TWAIN_AcquireToFilename("",Res)
If Res = 0 Then DrawStatusWinText(0,"Acquire to File Failed")
If Res = 1
DrawStatusWinText(0,"Acquire to File Successful")
FreeBitmap(Image13$)
DrawBitmap(0,0,Image13$)
Endif
UseCursor(ARROW)
Goto Wait_for_Input
AddBitmap:
LoadBitmap(Image1$,FULL)
Goto Wait_for_Input
FreeList:
FreeBitmapAll
Goto Wait_for_Input
ListList:
ListLoadedBitmaps(List$,CR$,Count)
If Count > 0
MessageBox(OK,1,INFORMATION,List$,"Loaded bitmaps",Res)
DrawBitmap(0,0,Image13$)
Endif
Goto Wait_for_Input